Skip to content

Add primary range repair type - #2021

Merged
tommystendahl merged 1 commit into
masterfrom
primary-range-repair-type
Nov 27, 2026
Merged

tommystendahl merged 1 commit into
masterfrom
primary-range-repair-type

Conversation

@tommystendahl

Copy link
Copy Markdown
Collaborator

Add repair type PRIMARY_RANGE (primary_range in the configuration), for scheduled and on-demand repairs. Every managed node runs a full repair of all its primary ranges in one repair session, like nodetool repair -pr.

Locks: the single slot table lock that incremental repair takes, so the two exclude each other per table, and one single slot lock per datacenter involved, named PrimaryRange- so it does not collide with the vnode datacenter lock. No per-node locks, repair.lock_type does not apply, and it is not coordinated with vnode repair.

History: the task records repair_history rows typed PRIMARY_RANGE, keyed by the coordinator node. They are read with the new RepairHistoryProvider.lastSuccessfulRepair, which does not map rows to token ranges, and the vnode repair state reader now skips them explicitly instead of dropping full-range rows by accident.

First repair: a table with no primary range repair in the history is taken for a new table, as for vnode repair, so its first repair waits for initial_delay. A history that cannot be read is not taken for no history, so a failing read does not delay a repair.

On demand: a cluster-wide request already creates one job per managed node, so OngoingJob.startClusterWideJob writes no extra rows for this type, which would have run every repair twice.

Every repair type dispatch point handles the new type explicitly, as required by the exhaustive switches from #1989. Unit tests pin the lock sets, the history separation and the per-type behavior.

Integration tests: test_primary_range_repair.py runs scheduled and on-demand primary range repairs on a 4 node, 2 datacenter cluster. It checks that the coordinators repair disjoint token ranges, that the history is recorded as PRIMARY_RANGE and read back after a restart, and that the repair needs the table lock and both datacenter locks but not the vnode locks. It runs as a suite of its own, in the new primary-range-repair-integration-tests profile and its local variant, which are split off from the incremental repair profiles and added to the CI workflow and scripts/run-ci.sh, together with the incremental suites that run-ci.sh was missing. Its cluster-free helpers are unit tested in the Python unit tests job. A behave scenario covers run-repair with the new type.

Alarms: a scheduled primary range job raises REPAIR_WARNING and REPAIR_ERROR at repair.alarm.warn and repair.alarm.error, using the threshold decision now shared with vnode repair (AlarmPostUpdateHook. faultCodeFor). The alarms carry the source PRIMARY_RANGE_ELAPSED so they do not collide with the vnode alarms of the same node and table. The reporter is only told when an alarm appears, escalates or clears, and the alarm is ceased when a repair succeeds or is found in the history.

Issue #2005

Add repair type PRIMARY_RANGE (primary_range in the configuration), for
scheduled and on-demand repairs. Every managed node runs a full repair of
all its primary ranges in one repair session, like nodetool repair -pr.

Locks: the single slot table lock that incremental repair takes, so the
two exclude each other per table, and one single slot lock per
datacenter involved, named PrimaryRange-<datacenter> so it does not
collide with the vnode datacenter lock. No per-node locks, repair.lock_type
does not apply, and it is not coordinated with vnode repair.

History: the task records repair_history rows typed PRIMARY_RANGE, keyed
by the coordinator node. They are read with the new
RepairHistoryProvider.lastSuccessfulRepair, which does not map rows to
token ranges, and the vnode repair state reader now skips them
explicitly instead of dropping full-range rows by accident.

First repair: a table with no primary range repair in the history is
taken for a new table, as for vnode repair, so its first repair waits
for initial_delay. A history that cannot be read is not taken for no
history, so a failing read does not delay a repair.

On demand: a cluster-wide request already creates one job per managed
node, so OngoingJob.startClusterWideJob writes no extra rows for this
type, which would have run every repair twice.

Every repair type dispatch point handles the new type explicitly, as
required by the exhaustive switches from #1989. Unit tests pin the lock
sets, the history separation and the per-type behavior.

Integration tests: test_primary_range_repair.py runs scheduled and
on-demand primary range repairs on a 4 node, 2 datacenter cluster. It
checks that the coordinators repair disjoint token ranges, that the
history is recorded as PRIMARY_RANGE and read back after a restart, and
that the repair needs the table lock and both datacenter locks but not
the vnode locks. It runs as a suite of its own, in the new
primary-range-repair-integration-tests profile and its local variant,
which are split off from the incremental repair profiles and added to
the CI workflow and scripts/run-ci.sh, together with the incremental
suites that run-ci.sh was missing. Its cluster-free helpers are unit
tested in the Python unit tests job. A behave scenario covers
run-repair with the new type.

Alarms: a scheduled primary range job raises REPAIR_WARNING and
REPAIR_ERROR at repair.alarm.warn and repair.alarm.error, using the
threshold decision now shared with vnode repair (AlarmPostUpdateHook.
faultCodeFor). The alarms carry the source PRIMARY_RANGE_ELAPSED so they
do not collide with the vnode alarms of the same node and table. The
reporter is only told when an alarm appears, escalates or clears, and the
alarm is ceased when a repair succeeds or is found in the history.

Issue #2005
@tommystendahl tommystendahl self-assigned this Nov 27, 2026
@tommystendahl
tommystendahl requested a review from a team as a code owner November 27, 2026 07:47
@tommystendahl tommystendahl added the enhancement New feature or request label Nov 27, 2026
@tommystendahl
tommystendahl merged commit 9cd1ac1 into master Nov 27, 2026
89 checks passed
@tommystendahl
tommystendahl deleted the primary-range-repair-type branch November 27, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Primary Range Repair Type for Full Repair of a Node's Primary Ranges

2 participants